import { createStore } from 'vuex';
import { IBaseMusicProps } from '@/type'

export interface IStoreStateProps {
  currentMusic: IBaseMusicProps | null;
}

export default createStore<IStoreStateProps>({
  state: {
    /** 当前播放的音乐 */
    currentMusic: null
  },
  mutations: {
    /** 设置当前播放音乐 */
    setCurrentMusic(state, music: IBaseMusicProps) {
      state.currentMusic = music;
    },
    /** 清除当前播放音乐 */
    clearCurrentMusic(state) {
      state.currentMusic = null
    },
    /** 设置当前音乐的播放状态 */
    setCurrentMusicPlayStaus(state,status: boolean){
      state.currentMusic = {
        ...state.currentMusic,
        isPlaying: status
      } as IBaseMusicProps
    }
  },
  actions: {
  },
  modules: {
  }
})
